#!usr/bin/node

const http = require('http'),
      url = require('url'),
      address = process.argv[2];

const opt = url.parse(global.encodeURI(address));
opt.headers = {
  'User-Agent':'01-my-curl.js'
};

http.get(opt,(res) => {
  console.log(`HTTP/${res.httpVersion} ${res.statusCode} ${res.statusMessage}`);
  console.log(res.headers);
  res.pipe(process.stdout);
})
